package model

import (
	"fmt"
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
)

var DB *gorm.DB

func InitGorm(MysqlDataSource string) *gorm.DB {
	var err error
	DB, err = gorm.Open(mysql.Open(MysqlDataSource), &gorm.Config{})
	if err != nil {
		panic("连接 mysql 数据库失败：" + err.Error())
	} else {
		fmt.Println("连接数据库成功")
	}
	return DB

}
